home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 19
/
Aminet 19 (1997)(GTI - Schatztruhe)[!][Jun 1997].iso
/
Aminet
/
gfx
/
conv
/
IFFAnimGIFAnim.lha
/
IFFAnim2GIFAnim.ifx
next >
Wrap
Text File
|
1997-03-27
|
7KB
|
229 lines
/* IFF anim to GIF anim arexx script for ImageFX 1.51+
*
* Using the original ConvertAnim.ifx source for loading in the anim, the
* extra IFFAnim>GIFAnim code is written by me, including scaling and
* cropping.
*
* (C) © 1997 by Ridwan Hughes <fox@ridhughz.demon.co.uk>
*
* Release V1.2
*
*
* Requirements:
* The files "WhirlGIF"(v2.01), "execute" and "run" to be in c:
* The dir "Env:ImageFX" to exist and for PIPE: to be mounted.
* Needs the render module called Foreign.
*
* Bugs:
* Subsequent animations will mess up totally if you break the script
* in the middle of it's operation.
* Won't work if you don't have the dir Env:ImageFX and also won't work
* without the files WhirlGif and execute available in c:
*
*
* History:
*
* 1.2 Fixed the loop and timing options. Removed the disposal option as my
* copy of ImageFX can't save transparent GIF's. Allowed user to select
* amount of colours used in the gif anim. Space in filename bug fixed.
* Added brightness, contrast and sharpen options which execute in that
* order. If sharpen is selected, the images are sharpened after any
* scaling is done. Fixed the bug when cropping an anim, the image used
* to be 1 pixel smaller (both x and y) than indicated.
*
* 1.1 Added simple cropping into the script. Transparent option taken out,
* as the GIF saver with ImageFX1.51 doesn't save transparent GIFs.
* Added the disposal option for WhirlGIF v2.01.
*
* 1.0 Initial release, few people got a copy, adds the loop+transparent+
* timing into WhirlGif's parameter input, also has image scaling.
*
*/
OPTIONS RESULTS
RequestFile '"Enter Source IFF Animation:"'
IF rc ~= 0 THEN EXIT 0
filename = result
RequestFile '"Enter Destination GIF Animation:"'
IF rc ~= 0 THEN EXIT 0
outfile = result
IF outfile=filename THEN DO
RequestNotify 'Cannot save over file being read in, please re-start'
EXIT 0
END
IF EXISTS(outfile) THEN DO
RequestResponse '"Output exists. Overwrite it?"'
IF rc ~= 0 THEN EXIT 0
END
Requestnotify 'Please select the 2nd to last frame'
Requestnotify 'as most IFF anims have 2 extra frames for looping'
open(nimov,'env:ImageFX/ANIM_Frame','W')
writech(nimov,'FFFF')
close(nimov)
LoadBuffer d2c(34)||filename||d2c(34) force
GetMain
PARSE VAR result name picwidth picheight depth .
open(nimoy,'env:ImageFX/ANIM_Frame','R')
frames=c2d(readch(nimoy,4))
close(nimoy)
if frames=1 THEN frames=2
whirlloop=''
RequestResponse 'Loop the GIF anim? (currently set to play once)'
IF rc=0 THEN do
RequestNumber '"Loop how many times? (0=infinite)"' 0
whirlloop='-loop'
IF rc=0 THEN whirlloop='-loop '||result
IF result=0 THEN whirlloop='-loop'
end
whirldeelay='-time 1'
RequestResponse 'Set a time delay between frames? (currently set at max speed)'
IF rc=0 THEN do
RequestNumber '"Time delay between frames (1/100 fps), 1=fastest speed"' 1
IF rc=0 THEN whirldeelay='-time '||result
end
kropme=0
RequestResponse 'Crop the anim?'
IF rc=0 THEN do
Requestnotify 'Please click on one corner'
WaitFor SELECTUP
parse var result x y
cropx1=x
cropy1=y
RequestNotify 'Now click on the opposite corner'
WaitFor SELECTUP
parse var result x y
cropx2=x
cropy2=y
VirtualBox cropx1 cropy1 cropx2 cropy2
RequestNotify 'This is the area to be cropped'
VirtualBox cropx1 cropy1 cropx2 cropy2
if cropx1<cropx2 then do
cropx3=cropx1
cropx1=cropx2
cropx2=cropx3
end
if cropy1<cropy2 then do
cropy3=cropy1
cropy1=cropy2
cropy2=cropy3
end
cropx1=cropx1+1
cropy1=cropy1+1
crop cropx2 cropy2 cropx1-cropx2 cropy1-cropy2
kropme=1
picwidth=cropx1-cropx2
picheight=cropy1-cropy2
end
bright=0
RequestResponse 'Change the brightness?'
IF rc=0 THEN do
RequestSlider '"New brightness setting (127=equal):"' 0 255 127
bright=result-127
if rc ~=0 THEN bright=0
if bright ~=0 THEN brightness bright
end
kontrast=0
RequestResponse 'Change the contrast?'
IF rc=0 THEN do
RequestSlider '"New contrast setting (127=equal):"' 0 255 127
kontrast=result-127
if rc ~=0 THEN kontrast=0
if kontrast ~=0 THEN contrast kontrast
end
skale=0
RequestResponse 'Scale the anim?'
IF rc=0 THEN do
oldpicwidth=picwidth
RequestSlider '"New width:"' 2 picwidth picwidth
IF rc = 0 THEN picwidth=result;skale=1
if oldpicwidth=picwidth THEN skale=0
aspec=(picwidth/oldpicwidth)*picheight
aspectext='"New height ('||aspec||' makes it even scaling):"'
oldpicheight=picheight
RequestSlider aspectext 2 picheight aspec
IF rc = 0 THEN picheight=result;skale=1
IF oldpicheight=picheight AND oldpicwidth=picwidth THEN skale=0
end
sharp=0
RequestResponse 'Sharpen the anim?'
IF rc=0 THEN do
RequestSlider '"Enter Sharpen Amount:"' 0 255 0
sharp=result
if rc ~=0 THEN sharp=0
if sharp>0 THEN sharpen sharp
end
Gadget.1 = 'Number of colours in anim (Cancel=256):'
Gadget.2 = '2'
Gadget.3 = '4'
Gadget.4 = '8'
Gadget.5 = '16'
Gadget.6 = '32'
Gadget.7 = '64'
Gadget.8 = '128'
Gadget.9 = '256'
colz=256
ListRequest 9 Gadget
IF rc = 0 THEN do
if Gadget.result=Gadget.2 THEN colz=2
if Gadget.result=Gadget.3 THEN colz=4
if Gadget.result=Gadget.4 THEN colz=8
if Gadget.result=Gadget.5 THEN colz=16
if Gadget.result=Gadget.6 THEN colz=32
if Gadget.result=Gadget.7 THEN colz=64
if Gadget.result=Gadget.8 THEN colz=128
end
open(feesh,'t:giflist','W')
writeln(feesh,'pipe:gif1')
do i=2 to frames
writeln(feesh,'pipe:gif'||i)
end
close(feesh)
open(feesh,'t:xe','W')
writeln(feesh,'run >NIL: c:whirlgif '||whirlloop||' '||whirldeelay||' -o '||d2c(34)||outfile||d2c(34)||' -i t:giflist')
close(feesh)
address command 'execute t:xe'
SetPrefs Undo Off
Menu Render
SetRender Foreign
Render Mode Lores Nolace
Render Colors colz
DO i = 1 to frames
LoadBuffer d2c(34)||filename||d2c(34) Force i /* load a frame */
IF rc ~= 0 THEN LEAVE /* oops... end of file, exit */
IF kropme=1 then crop cropx2 cropy2 cropx1-cropx2 cropy1-cropy2 /* crop */
IF bright ~=0 THEN brightness bright /* change the brightness */
IF kontrast ~=0 THEN contrast kontrast /* change the contrast */
IF skale=1 then Scale picwidth picheight /* scale the image */
IF sharp>0 THEN sharpen sharp /* sharpen the image */
Render Go /* uses current render settings */
SaveRenderedAs GIF 'pipe:gif'||i /* save GIF to pipe: */
END
SetPrefs Undo On
Requestnotify 'Your GIF anim is now complete.'
EXIT 0